package com.kumarn.android.test.gcmtest;

import com.google.android.gcm.GCMBaseIntentService;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class GCMIntentService extends GCMBaseIntentService  {

	private static String SENDER_ID = "905158088538";

	public GCMIntentService() {
		super(SENDER_ID);
	}

	@Override
	public void onRegistered(Context context, String registrationId) {
		Log.w("registration id:", registrationId);
		sendMessage("id:" + registrationId);
	}

	@Override
	protected void onUnregistered(Context context, String registrationId) {
		sendMessage("C2DM Unregistered");
	}

	@Override
	public void onError(Context context, String errorId) {
		sendMessage("err:" + errorId);
	}

	@Override
	protected void onMessage(Context context, Intent intent) {
		String str = intent.getStringExtra("message");
		Log.w("message:", str);
		sendMessage(str);
	}

	private void sendMessage(String str) {
		// メッセージ受信時の動作を記述
	}
}